package com.ruoyi.file.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.file.service.ISysFileService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文件请求处理。
 *
 * @author william.zhao & zhao xiang.
 * @version 1.0
 * @date 2023/05/05
 * @since jdk-17.0.2
 */
@RestController
public class SysFileController {
    private static final Logger log = LoggerFactory.getLogger(SysFileController.class);

    @Autowired
    private ISysFileService sysFileService;

    /**
     * get file content.
     *
     * @param fileURL file url.
     * @return file content.
     */
    @PostMapping("get_content")
    public R<String> getFileContent(String fileURL, String extension) {
        String content = sysFileService.getContentByURL(fileURL, extension);
        return R.ok(content);
    }


}
